<script  >
//// 创建表格头部
export default {
  components: {},

  data() {
    return {

    };
  },
  watch: {

  },

  inject: ["edit"],
  methods: {
    sync (prop, value) {
      this[prop] = value;
    },

    createHead(h) {
      let [tr] = [[]];

      this.edit.resetNewColHead.forEach((x) => {
        let cell = [];
        x.forEach((y) => {
          if (y) {
            let height = y.colSpan * this.edit.tableTdHeight;

            let subIcon = h('img', { attrs: { src: y.iconPath } }, []);
            let treeAddIcon = h('img', { attrs: { src: 'statics/icons/table/iconadd2.svg' }, style: { width: '12px', margin: '10px'  } }, []);
            let treeSpreadIcon = h('img', { attrs: { src: 'statics/icons/table/iconspread2.svg' }, style: { width: '12px', margin: '10px' } }, []);
            let tmpClass =   y.rowSpan === 1  && y.colSpan > 1 ? 'verticalCol colCell' : 'horizontalCol';
            let atooltip =   h('span', {  }, y.displayTitle);
            let contentCell = y.children.length > 0 ? [treeSpreadIcon, atooltip] : [ subIcon, atooltip];
            if (this.edit.treeToggleCol[y.id]){
              tmpClass = 'horizontalCol colCell';
              contentCell = [treeAddIcon, atooltip];
            }

            let subCell = h('div', { class: tmpClass, style: { height: (height - 2) + "px" } }, contentCell);
            //// getAttribute
            
            cell.push(h('th', { style: { height: height + "px" }, attrs:
               { colspan: y.rowSpan, rowspan: y.colSpan, 'data-key': y.id, 'data-type': 'col' }
            }, [subCell]));
          }
        });
        //// tr.push(<tr>{cell}</tr>);
        tr.push(h('tr', {}, [cell]));
      });

      return tr;
    },

  },
  render(h) {
    let tr = this.createHead(h);
    //// return <table class="editTable__block" id="tb"><thead>{tr}</thead></table>
    return h('table', { 'class': {
      editTableBlock: true,
      headtable: true
    }, attrs: {
      style: 'table-layout:fixed;overflow:hidden;z-index:0;'
    } }, [h('thead', {}, [tr])]);
  }
};
</script>
<style lang="scss"></style>
